<?php

namespace catchAdmin\pc\tables;

use catchAdmin\model\Area;
use catchAdmin\pc\tables\forms\Factory;
use catchAdmin\permissions\model\Permissions;
use catcher\CatchTable;
use catcher\library\table\Actions;
use catcher\library\table\HeaderItem;
use catcher\library\table\Search;
use catcher\library\form\Form;
use think\facade\Cache;

class NeedDesign extends CatchTable
{

    public function Table()
    {
        return $this
            ->getTable('needDesign')
            ->header([
                HeaderItem::label('标题')->prop('need_title'),
                HeaderItem::label('地址')->prop('need_city_name'),
                HeaderItem::label('是否加急')->prop('project_jia_ji_name'),
                HeaderItem::label('提交时间')->prop('created_at'),
                HeaderItem::label('审核状态')->prop('status_name'),
                HeaderItem::label('审核时间')->prop('status_time_show'),
                HeaderItem::label('操作')->actions([
                    Actions::view(),
                    Actions::normal('付费公司', 'success', 'handleMatchUserCompany'),
                ])
                    ->width(260),
            ])
            ->withSearch([
                Search::label('标题')->text('need_title', '标题')->clearable(true),
                Search::label('是否加急')->select('project_jia_ji', '是否加急', tableSelectArray((new \catchAdmin\model\Need())->getProjectJiaJiList()))->clearable(true),
                Form::cascader('need_city_code', '地区', [])->options(
                    (new Area())
                        ->indexTree()
                )
                    ->col(12)
                    ->props(Form::props('label', 'value', [
                        'checkStrictly' => true,
                    ]))
                    ->filterable(true)
                    ->clearable(true)
                    ->style(['width' => '100%']),

            ])
            ->selectionChange()
            ->withApiRoute('needDesign')
            ->withActions([
            ])
            ->render();
    }


    public function form()
    {
        return Factory::create('needDesign');
    }

}
